from pyecharts.charts import Bar
from pyecharts import options as opts
import pandas as pd
import numpy as np
file="E:\\djangoProject\\Try\\人智能.csv"
data=pd.read_csv(file,encoding='GBK',sep=',')
title=list(data.get('title'))[:10]
download=list(data.get('download'))[:10]
list_a=[elem if not np.isnan(elem) else None for elem in download]
print(len(list_a))
zd={}
for i in range(len(list_a)):
    if list_a[i]==None:
        list_a[i]=0
list_a.sort()
bar = (
    Bar()
    .add_xaxis(title)
    .add_yaxis("大数据类型论文",list_a,category_gap="30%")
    .set_global_opts(title_opts=opts.TitleOpts(title="文章下载量显示"),xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=-90)),
                     legend_opts=opts.LegendOpts(pos_left=300),
                     yaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(formatter="{value} /篇")),)
)
# bar.render_notebook()#在Notebook中进行渲染图像
bar.render("try.html")#在本地生成静态网页